package com.edu.d3_polymorphic_test;

public class Computer {
    private String name;

    public Computer() {
    }

    public Computer(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    /**
     * 提供usb接口的功能
     */
    public void addUSB(USB usb){
        //多态
        usb.connect();
        if(usb instanceof KeyBorad){
            KeyBorad keyBorad = (KeyBorad) usb;
            keyBorad.Click();
        }else if(usb instanceof Mouse){
            Mouse mouse = (Mouse) usb;
            mouse.dbClick();
        }
        usb.unconnect();
    }
    public void start(){
        System.out.println(name+"开机了");
    }
}
